<script lang="ts" setup>
import { ref, reactive, onMounted, watch } from 'vue';
import getTableData from '/@/utils/getTableData';
import {
	getStageListApi,
	delStageListApi,
	editStageListApi,
	addStageListApi,
	getStageListSelectApi,
	delStageTodoListApi,
	getStageListDetailApi,
	getStageTodoListApi,
	addStageTodoListApi,
	editStageTodoListApi,
	deleteProjectTodoSubItemApi,
	updateProjectTodoSubItemApi,
	addProjectTodoSubItemApi,
	getProjectTodoSubItemApi,
} from '/@/api/sms/HazardousChemicalsInterface';
import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
import SearchModel from '/@/views/sms/component/search-model.vue';
import { exportToExcel } from '/@/utils/exportToExcel';
/***** 查询 *****/
let searchObj: any = reactive({});
const transferVal = ref();
const searchClick = () => {
	// searchObj.Stage_Name = transferVal.value;
	let newObj = Object.keys(searInfo.value);
	if (newObj.length !== 0) {
		newObj.map((i: any) => {
			searchObj[i] = searInfo.value[i];
		});
	}
};

const resetClick = () => {
	// transferVal1.value = ''
	// transferVal2.value = ''
	searInfo.value = {};
	let newObj = Object.keys(searchObj);
	if (newObj.length !== 0) {
		newObj.map((i: any) => {
			searchObj[i] = '';
			// console.log(i);
		});
	}
	initInfoFun();
};

/***** 新增 *****/
const showDialogVisible = ref(false);
const ruleForm = reactive({
	stageName: '',
	stageLevel: null,
});
const addNodeClick = async () => {
	showDialogVisible.value = true;
};

/***** 编辑 *****/
const saveId = ref();
const nodeClick = async (row: any) => {
	if (row.n_Id) {
		saveId.value = row.n_Id;
		ruleForm.stageLevel = row.stage_Level;
		ruleForm.stageName = row.stage_Name;
	}
	showDialogVisible.value = true;
};

/*** 删除 */
const deleteHandle = async (val: String | Number) => {
	ElMessageBox.confirm('请确定删除此条数据', '提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning',
	})
		.then(async () => {
			let param = { n_Id: val };
			try {
				let res: any = await delStageListApi(param);
				if (res.success) {
					getData();
				}
			} catch (err) {
				return;
			}
		})
		.catch(() => {
			ElMessage({
				type: 'info',
				message: '删除失败',
			});
		});
};

/***** 新增表单校验和事件 *****/
const ruleFormRef = ref();
const rules = reactive({
	stageName: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
	stageLevel: [
		{ required: true, message: '内容不能为空', trigger: 'blur' },
		{ pattern: /^[1-9]\d*$/, message: '请输入正整数', trigger: 'blur' },
	],
});

const cancelUseClick = () => {
	showDialogVisible.value = false;
	ruleForm.stageName = '';
	ruleForm.stageLevel = null;
	saveId.value = '';
};
const controlUseClick = async (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	await formEl.validate((valid, fields) => {
		if (valid) {
			if (saveId.value) {
				const item1 = list.value.find((item) => item.n_Id == saveId.value);
				const item2 = list.value.find((item) => item.stage_Level == ruleForm.stageLevel) || '';
				console.log(item1, item2);
				//   if(item1.n_Id !== item2.n_Id && item1.stage_Level == ruleForm.stageLevel)
				if (item1.n_Id !== item2.n_Id && item2.stage_Level == ruleForm.stageLevel) {
					ElMessage.warning('该等级已存在');
					return;
				} else {
					let param = {
						n_Id: saveId.value,
						stage_Level: Number(ruleForm.stageLevel),
						stage_Name: ruleForm.stageName,
					};
					editStageListApi(param).then(() => {
						cancelUseClick();
						getData();
					});
				}
			} else {
				let list1 = list.value.map((i) => {
					return i.stage_Level;
				});
				console.log(list1, Number(ruleForm.stageLevel));
				let bl = list1.some((item) => item == Number(ruleForm.stageLevel));
				console.log(bl);
				if (bl) {
					ElMessage.warning('该等级已存在');
					return;
				} else {
					addStageListApi(ruleForm).then((res) => {
						if (res.success) {
							cancelUseClick();
							getData();
						}
					});
				}
			}
		} else {
			console.log('error submit!', fields);
		}
	});
};

/*** detailHandle 查看详情事件 */
const showDetailDialogVisible = ref(false);
const tableData = ref();
const detailHandle = async (item: any) => {
	const res = await getStageListDetailApi({ StageId: item.n_Id });
	console.log(res);
	tableData.value = res.data;
	showDetailDialogVisible.value = true;
};

const cancelDetailClick = () => {
	showDetailDialogVisible.value = false;
};

// 阶段代办
const tableDataTodo = ref([]);
const showTodoDialogVisible = ref(false);
const ruleFormTodoRef = ref();
const ruleFormTodo = reactive({
	stageId: '',
	stageTodoName: '',
});
const rulesTodo = reactive({
	stageTodoName: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
});
const editClick = async (row: any) => {
	ruleFormTodo.stageId = row.n_Id;
	const res = await getStageTodoListApi({ stageId: row.n_Id });
	console.log(res);
	tableDataTodo.value = res.data;
	showTodoDialogVisible.value = true;
};

const cancelTodoClick = () => {
	showTodoDialogVisible.value = false;
	tableDataTodo.value = [];
	ruleFormTodo.stageTodoName = '';
	ruleFormTodo.stageId = '';
	editId.value = 0;
	ruleFormTodoRef.value.clearValidate();
};

// 新增修改阶段代办
const addTodoClick = async (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	await formEl.validate((valid, fields) => {
		if (valid) {
			if (editId.value) {
				let param = {
					stageId: ruleFormTodo.stageId,
					stageTodo_Name: ruleFormTodo.stageTodoName,
				};
				editStageTodoListApi({ ...param, n_Id: editId.value }).then((res) => {
					getStageTodoListApi({ stageId: ruleFormTodo.stageId }).then((res) => {
						console.log(res);
						tableDataTodo.value = res.data;
						resetTodoClick();
					});
				});
			} else {
				addStageTodoListApi(ruleFormTodo).then((res) => {
					getStageTodoListApi({ stageId: ruleFormTodo.stageId }).then((res) => {
						console.log(res);
						tableDataTodo.value = res.data;
						ruleFormTodo.stageTodoName = '';
					});
				});
			}
		} else {
			console.log('error submit!', fields);
		}
	});
};
//阶段代办重置
const resetTodoClick = () => {
	ruleFormTodo.stageTodoName = '';
	editId.value = 0;
};
// 修改阶段代办
const editId = ref(0);
const editTodoClick = (row: any) => {
	editId.value = row.n_Id;
	ruleFormTodo.stageTodoName = row.stageTodo_Name;
};
// 阶段代办删除
const deleteTodoClick = async (val: String | Number) => {
	ElMessageBox.confirm('请确定删除此条数据', '提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning',
	})
		.then(async () => {
			let param = { id: val };
			try {
				let res: any = await delStageTodoListApi(param);
				if (res.success) {
					ElMessage.success(res.message);

					getStageTodoListApi({ stageId: ruleFormTodo.stageId }).then((res) => {
						console.log(res);
						tableDataTodo.value = res.data;
						resetTodoClick();
					});
				}
			} catch (err) {
				return;
			}
		})
		.catch(() => {
			ElMessage({
				type: 'info',
				message: '删除失败',
			});
		});
};

// 阶段代办子项
const showTodoItemDialogVisible = ref(false);
const rulesTodoItem = reactive({
	stageTodoSubItemName: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
});
const ruleFormTodoItem = reactive({
	StageTodoId: '',
	stageTodoSubItemName: '',
});
const ruleFormTodoItemRef = ref();

const editTodoItemId = ref(0);
const projectTodoSubItemData: any = ref([]);
const todoItemClick = async (row: any) => {
	console.log(row, 'row');
	ruleFormTodoItem.StageTodoId = row.n_Id;
	const res = await getProjectTodoSubItemApi({ StageTodoId: row.n_Id });
	projectTodoSubItemData.value = res.data;
	showTodoItemDialogVisible.value = true;
};

const resetTodoItemClick = () => {
	ruleFormTodoItem.stageTodoSubItemName = '';
	editTodoItemId.value = 0;
};
const addTodoItemClick = async (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	await formEl.validate((valid, fields) => {
		if (valid) {
			if (editTodoItemId.value) {
				updateProjectTodoSubItemApi({ ...ruleFormTodoItem, n_Id: editTodoItemId.value }).then((res) => {
					getProjectTodoSubItemApi({ StageTodoId: ruleFormTodoItem.StageTodoId }).then((res) => {
						console.log(res);
						projectTodoSubItemData.value = res.data;
						resetTodoItemClick();
					});
				});
			} else {
				addProjectTodoSubItemApi(ruleFormTodoItem).then((res) => {
					getProjectTodoSubItemApi({ StageTodoId: ruleFormTodoItem.StageTodoId }).then((res) => {
						console.log(res);
						projectTodoSubItemData.value = res.data;
						resetTodoItemClick();
					});
				});
			}
		} else {
			console.log('error submit!', fields);
		}
	});
};

const cancelTodoItemChildClick = () => {
	ruleFormTodoItemRef.value.clearValidate();
	resetTodoItemClick();
	projectTodoSubItemData.value = [];
};
const editTodoItemClick = (row: any) => {
	console.log(row, 'row');
	editTodoItemId.value = row.n_Id;
	ruleFormTodoItem.stageTodoSubItemName = row.stageTodoSubItemName;
};
const deleteTodoItemClick = async (val: String | Number) => {
	ElMessageBox.confirm('请确定删除此条数据', '提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning',
	})
		.then(async () => {
			let param = { n_id: val };
			try {
				let res: any = await deleteProjectTodoSubItemApi(param);
				if (res.success) {
					ElMessage.success(res.message);
					getProjectTodoSubItemApi({ StageTodoId: ruleFormTodoItem.StageTodoId }).then((res) => {
						console.log(res);
						projectTodoSubItemData.value = res.data;
						resetTodoItemClick();
					});
				}
			} catch (err) {
				return;
			}
		})
		.catch(() => {
			ElMessage({
				type: 'info',
				message: '删除失败',
			});
		});
};

/*** 初始化数据 */
const basicsInfo: any = ref([]);
const initInfoFun = () => {
	basicsInfo.value = [
		{
			typeId: 'stage_Name', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
			typeNam: '', // 输入类型(number,text等) --- 选填
			searchVal: 'Stage_Name', // 查询字段 --- 必填
			defaultVal: '', // 字段默认值 --- 选填
			placeholder: '阶段名称', // placeholder数据
			defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
			eventType: '', // 事件类型（如burl/change等） --- 选填
			defaultEvent: '', // 事件名称 --- 选填
		},
		// {
		// 	typeId: 'assesseeName', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
		// 	typeNam: '', // 输入类型(number,text等) --- 选填
		// 	searchVal: 'AssesseeId', // 查询字段 --- 必填
		// 	defaultVal: '', // 字段默认值 --- 选填
		// 	placeholder: '被考核人', // placeholder数据
		// 	defaultProp: options1.value, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
		// 	eventType: '', // 事件类型（如burl/change等） --- 选填
		// 	defaultEvent: '', // 事件名称 --- 选填
		// },
	];
};

const searInfo: any = ref();
const searchHandel = (val: any) => {
	searInfo.value = val;
};

/*** ================================= 导出数据函数操作 ================================= */
const excelRef: any = ref(null);
const handleExport = () => {
	if (excelRef.value) {
		if (excelRef.value.data.length !== 0) {
			let tableExcel: any = [];
			let tableArr = excelRef.value.data;
			tableArr.map((item: any) => {
				let tableObj: any = {};
				tableObj['阶段等级'] = item.stage_Level ? item.stage_Level : '-';
				tableObj['阶段名称'] = item.stage_Name ? item.stage_Name : '-';

				tableObj['创建人'] = item.createdUserName ? item.createdUserName : '-';
				tableObj['创建时间'] = item.createdTime ? item.createdTime : '-';
				tableObj['更新人'] = item.updatedUserName ? item.updatedUserName : '-';
				tableObj['更新时间'] = item.updatedTime ? item.updatedTime : '-';
				tableExcel.push(tableObj);
			});
			exportToExcel(tableExcel, '阶段管理.xlsx');
		} else {
			ElMessage({
				type: 'error',
				message: '暂无数据导出',
			});
		}
	}
};

const { handleCurrentChange, pageSize, pageNo, handleSizeChange, totalRows, list, indexMethod, loading, getData } = getTableData(getStageListApi, {}, searchObj);

onMounted(async () => {
	await initInfoFun();
});
</script>

<template>
	<div id="friend-merchant-manage" class="w-h-100 pos-r flex-1 apply-container" style="box-sizing: border-box; overflow: hidden">
		<div class="w-h-100 ver-flex pos-a" style="box-sizing: border-box; padding: 6px">
			<div class="search-s page-public-s" style="box-sizing: border-box">
				<el-card shadow="never" :body-style="{ paddingBottom: '0' }">
					<el-form class="box-f" ref="queryForm" :inline="true">
						<!-- <el-form-item label="阶段名称：">
							<el-input v-model="transferVal" placeholder="请输入阶段名称" />
						</el-form-item> -->
						<el-form-item>
							<el-button v-if="$hasPer('stageManagement1:add')" @click="addNodeClick" icon="ele-Plus" type="primary"> 新增 </el-button>
							<el-button v-if="$hasPer('stageManagement7:excel')" @click="handleExport" icon="ele-Download"> 导出数据 </el-button>
						</el-form-item>
					</el-form>
				</el-card>
			</div>

			<div style="box-sizing: border-box" class="flex-1 pos-r">
				<div class="pos-a w-h-100" style="box-sizing: border-box">
					<el-card class="box-card w-h-100" shadow="never" style="margin-top: 16px">
						<div style="" class="w-h-100 ver-flex">
							<div class="flex-1 pos-r">
								<div class="pos-a w-h-100">
									<el-table ref="excelRef" :data="list" class="w-h-100" style="width: 100%" border v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.5)">
										<el-table-column type="index" label="序号" width="55" :show-overflow-tooltip="true" align="center" :index="indexMethod" />
										<el-table-column min-width="120" :show-overflow-tooltip="true" prop="stage_Level" label="阶段等级" align="center" />
										<el-table-column min-width="120" :show-overflow-tooltip="true" label="阶段名称" align="center">
											<el-table-column min-width="120" :show-overflow-tooltip="true" align="center">
												<template #header>
													<SearchModel typeId="stage_Name" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
												</template>
												<template #default="{ row }">
													{{ row.stage_Name }}
												</template>
											</el-table-column>
										</el-table-column>
										<el-table-column min-width="120" :show-overflow-tooltip="true" prop="createdTime" label="创建时间" align="center" />
										<el-table-column min-width="120" :show-overflow-tooltip="true" prop="createdUserName" label="创建人" align="center" />
										<el-table-column min-width="120" :show-overflow-tooltip="true" label="更新时间" align="center">
											<template #default="scope">
												<span v-if="scope.row.updatedTime">{{ scope.row.updatedTime }}</span>
												<span v-else> - </span>
											</template>
										</el-table-column>
										<el-table-column min-width="120" :show-overflow-tooltip="true" label="更新人" align="center">
											<template #default="scope">
												<span v-if="scope.row.updatedUserName">{{ scope.row.updatedUserName }}</span>
												<span v-else> - </span>
											</template>
										</el-table-column>
										<el-table-column min-width="180" label="操作" align="center" fixed="right">
											<el-table-column min-width="180" align="center" fixed="right">
												<template #header>
													<el-button @click="searchClick" icon="ele-Search" type="primary" text> 查询 </el-button>
													<el-button @click="resetClick" icon="ele-Refresh" text> 重置 </el-button>
												</template>
												<template #default="scope">
													<div class="operate-s">
														<el-button @click="detailHandle(scope.row)" class="icon-e" icon="ele-View" size="small" text type="success"> 详情 </el-button>
														<el-button v-if="$hasPer('stageManagement2:edit')" @click="nodeClick(scope.row)" class="icon-e" icon="ele-Edit" size="small" text type="primary"> 编辑 </el-button>
														<el-button v-if="$hasPer('stageManagement3:create')" @click="editClick(scope.row)" class="icon-e" icon="ele-Plus" size="small" text type="primary"> 阶段代办 </el-button>
														<el-button v-if="$hasPer('stageManagement4:delete')" @click="deleteHandle(scope.row.n_Id)" class="icon-e" icon="ele-Delete" size="small" text type="danger">
															删除
														</el-button>
													</div>
												</template>
											</el-table-column>
										</el-table-column>
									</el-table>
								</div>
							</div>
							<div style="height: 30px; margin-top: 20px" class="hr-flex-start">
								<el-pagination
									v-model:currentPage="pageNo"
									v-model:page-size="pageSize"
									:total="totalRows"
									:page-sizes="[10, 20, 50, 100]"
									small
									background
									@size-change="handleSizeChange"
									@current-change="handleCurrentChange"
									layout="total, sizes, prev, pager, next, jumper"
									class="w-h-100"
								/>
							</div>
						</div>
					</el-card>
				</div>
			</div>
		</div>
		<!-- 新增and编辑 -->
		<el-dialog draggable :close-on-click-modal="false" :close-on-press-escape="false" v-model="showDialogVisible" :title="saveId ? '编辑' : '新增'" width="50%" @close="cancelUseClick">
			<el-form label-width="110px" ref="ruleFormRef" :model="ruleForm" size="default" :rules="rules">
				<el-divider content-position="left"> 基本信息 </el-divider>
				<el-row :gutter="35">
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item prop="stageName" label="阶段名称">
							<el-input v-model="ruleForm.stageName" placeholder="阶段名称" clearable />
							<!-- <el-select v-model="selectData.orgId" placeholder="组织" style="width: 100%"
                                @change="changeAssessee">
                                <el-option v-for="item in options4" :key="item.value" :label="item.label"
                                    :value="item.value" />
                            </el-select> -->
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item prop="stageLevel" label="阶段等级">
							<el-input v-model="ruleForm.stageLevel" placeholder="阶段等级" clearable />
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>

			<template #footer>
				<span class="dialog-footer">
					<el-button @click="cancelUseClick">取消</el-button>
					<el-button type="primary" @click="controlUseClick(ruleFormRef)">确定</el-button>
				</span>
			</template>
		</el-dialog>
		<!-- 详情 -->
		<el-dialog draggable :close-on-click-modal="false" :close-on-press-escape="false" v-model="showDetailDialogVisible" title="详情" width="50%" @close="cancelDetailClick">
			<el-divider content-position="left"> 基本信息 </el-divider>
			<el-descriptions class="margin-top" :column="2" border>
				<el-descriptions-item>
					<template #label> 阶段等级 </template>
					{{ tableData.stage_Level }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label> 阶段名称 </template>
					{{ tableData.stage_Name }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label> 创建时间 </template>
					{{ tableData.createdTime }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label> 更新时间 </template>
					{{ tableData.updatedTime }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label> 创建人 </template>
					{{ tableData.createdUserName }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label> 更新人 </template>
					{{ tableData.updatedUserName }}
				</el-descriptions-item>
			</el-descriptions>
			<el-divider content-position="left"> 阶段代办 </el-divider>
			<el-table :data="tableData.stageTodos" border style="width: 100%">
				<el-table-column type="index" label="序号" width="60" align="center" />
				<!-- <el-table-column prop="n_Id" label="阶段待办id" min-width="120" :show-overflow-tooltip="true" align="center" /> -->
				<el-table-column prop="stageTodo_Name" label="阶段待办名称" min-width="120" :show-overflow-tooltip="true" align="center" />
			</el-table>
		</el-dialog>
		<!-- 阶段代办 -->
		<el-dialog draggable :close-on-click-modal="false" :close-on-press-escape="false" v-model="showTodoDialogVisible" title="阶段代办" width="50%" @close="cancelTodoClick">
			<el-form label-width="110px" ref="ruleFormTodoRef" :model="ruleFormTodo" size="default" :rules="rulesTodo">
				<el-divider content-position="left"> 基本信息 </el-divider>
				<el-row :gutter="35">
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item prop="stageTodoName" label="阶段代办名称">
							<el-input v-model="ruleFormTodo.stageTodoName" placeholder="阶段代办名称" clearable />
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item>
							<el-button v-if="!editId" @click="addTodoClick(ruleFormTodoRef)" class="icon-e" icon="ele-Plus" type="primary"> 新增 </el-button>
							<el-button v-else @click="addTodoClick(ruleFormTodoRef)" class="icon-e" icon="ele-Edit" type="primary"> 修改 </el-button>
							<el-button @click="resetTodoClick" class="icon-e" icon="ele-Refresh"> 重置 </el-button>
						</el-form-item>
					</el-col>
				</el-row>
				<el-divider content-position="left"> 阶段代办列表 </el-divider>
				<el-table :data="tableDataTodo" border style="width: 100%">
					<el-table-column type="index" align="center" label="序号" width="80" />
					<el-table-column prop="stageTodo_Name" label="阶段待办名称" min-width="120" :show-overflow-tooltip="true" align="center" />
					<el-table-column align="center" label="操作" min-width="100" :show-overflow-tooltip="true">
						<template #default="{ row }">
							<el-button @click="todoItemClick(row)" class="icon-e" icon="ele-Plus" type="primary" text> 阶段代办子项 </el-button>
							<el-button @click="editTodoClick(row)" class="icon-e" icon="ele-Edit" type="primary" text> 编辑 </el-button>
							<el-button @click="deleteTodoClick(row.n_Id)" class="icon-e" icon="ele-Delete" type="danger" text> 删除 </el-button>
						</template>
					</el-table-column>
				</el-table>
			</el-form>
		</el-dialog>

		<!-- 阶段代办子项 -->
		<el-dialog draggable :close-on-click-modal="false" :close-on-press-escape="false" v-model="showTodoItemDialogVisible" title="阶段代办子项" width="50%" @close="cancelTodoItemChildClick">
			<el-divider content-position="left"> 新增阶段代办子项 </el-divider>
			<el-form style="overflow: hidden" label-width="110px" ref="ruleFormTodoItemRef" :model="ruleFormTodoItem" size="default" :rules="rulesTodoItem">
				<el-row :gutter="35">
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item prop="stageTodoSubItemName" label="阶段代办子项">
							<el-input v-model="ruleFormTodoItem.stageTodoSubItemName" placeholder="阶段代办子项" clearable />
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item>
							<el-button v-if="!editTodoItemId" @click="addTodoItemClick(ruleFormTodoItemRef)" class="icon-e" icon="ele-Plus" type="primary"> 新增 </el-button>
							<el-button v-else @click="addTodoItemClick(ruleFormTodoItemRef)" class="icon-e" icon="ele-Edit" type="primary"> 修改 </el-button>
							<el-button @click="resetTodoItemClick" class="icon-e" icon="ele-Refresh"> 重置 </el-button>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<el-table :data="projectTodoSubItemData" border style="width: 100%">
				<el-table-column type="index" align="center" label="序号" width="80" />
				<!-- <el-table-column prop="stageTodoId" align="center" label="阶段代办子项id" min-width="100" :show-overflow-tooltip="true" /> -->
				<el-table-column prop="stageTodoSubItemName" align="center" label="阶段代办子项名称" min-width="120" :show-overflow-tooltip="true" />
				<el-table-column align="center" label="操作" min-width="120" :show-overflow-tooltip="true">
					<template #default="{ row }">
						<el-button @click="editTodoItemClick(row)" class="icon-e" icon="ele-Edit" type="primary" text> 编辑 </el-button>
						<el-button @click="deleteTodoItemClick(row.n_Id)" class="icon-e" icon="ele-Delete" type="danger" text> 删除 </el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-dialog>
	</div>
</template>

<style lang="scss">
@import '../../style/public.scss';
</style>

<style scoped lang="scss">
#friend-merchant-manage {
	.box-f {
		:deep(.el-form-item__label) {
			padding: 0;
		}
	}

	:deep(.el-card__body) {
		height: 100%;
	}

	:deep(.el-card) {
		border: none !important;
	}

	.upload-demo {
		margin-left: 12px;
		margin-top: 2px;
	}

	ul {
		list-style: none;

		li {
			cursor: pointer;

			&:hover {
				color: red;
			}
		}
	}

	.icon-e {
		:deep(.el-icon) {
			margin-right: 0px !important;
		}
	}
}
</style>
